Speed up creating Mark objects in the Cython version#848
Speed up creating Mark objects in the Cython version#848
Conversation
|
Thanks, this looks like some low-hanging fruit for a nice speed boost! I don't love changing all the Cython callsites to use the two-call pattern, though... I might try playing with a cdef factory method that could accomplish the same thing with a single callsite (or feel free to do so yourself if you're interested!)- IIRC we've got a lot of flexibility there since we're not worried about non-Cython subclasses of this |
|
I didn't make a helper because Cython would end up ref counting the Mark object being passed around in the helper.. It might not make much difference though. Will test |
|
Still a nice speed up even with the helper. Note that 3.1 got a bit faster already since I opened this PR With Cython 3.1
|
|
Pushed another one that a bit different. Single call point but it does have a bit more maintenance burden. 688ebe7 |
main 192,792,792ns
this PR 168,216,041ns
Benchmark https://github.com/bdraco/pyyaml/blob/bench/tests_bench/benchmarks/test_simple_load.py (execute with
pytest --codspeed tests_bench/benchmarks/test_simple_load.py)Cython analysis via
cythonize -X language_level=3 -a -i yaml/_yaml.pyxBefore

After
